import { defineFakeRoute } from "vite-plugin-fake-server/client";
import dayjs from "dayjs";
import { clone } from "@pureadmin/utils";

const date = dayjs(new Date()).format("YYYY-MM-DD");

export default defineFakeRoute([
  // 用户管理
  {
    url: "/overview",
    method: "post",
    response: ({ body }) => {
      let list = [
        {
          date: "2022-11-22 13:23",
          name: "什么是建筑垃圾？",
          count1: "4",
          count: "32"
        },
        {
          date: "2024-09-03 11:09",
          name: "《节约用水条例》何时颁布实施？",
          count1: "3",
          count: "77"
        },
        {
          date: "2019-06-30 15:24",
          name: "文明使用公厕的要求是什么？",
          count1: "8",
          count: "4"
        },
        {
          date: "2023-10-12 10:13",
          name: "哪些生产经营单位应当设置安全生产管理机构？",
          count1: "9",
          count: "6"
        }
      ];
      if (body!.name) {
        list = list.filter(v => v.name.includes(body.name));
      }

      return {
        success: true,
        data: {
          list: list,
          total: list.length, // 总条目数
          pageSize: 20, // 每页显示条目个数
          currentPage: 1 // 当前页数
        }
      };
    }
  }
]);
